<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>星辰诞愿 - 发布公告</title>
    <style>
        /* Birthday Theme Styles */
        body {
            margin: 0;
            padding: 0;
            font-family: 'Comic Sans MS', cursive, sans-serif;
            background: linear-gradient(135deg, #fff5f5 0%, #fff0f5 100%);
            min-height: 100vh;
        }
        .nav {
            display: flex;
            align-items: center;
            padding: 15px 30px;
            background: rgba(255,255,255,0.95);
            box-shadow: 0 2px 15px rgba(210, 51, 105, 0.1);
            position: fixed;
            width: 100%;
            top: 0;
            z-index: 1000;
            border-bottom: 3px solid #ff8e9e;
        }
        .nav img {
            height: 50px;
            margin-right: 15px;
        }
        .blog-title {
            font-size: 24px;
            font-weight: bold;
            color: #d23369;
            text-shadow: 1px 1px 2px rgba(0,0,0,0.1);
            position: absolute;
            left: 100px;
        }
        .nav-links {
            display: flex;
            position: absolute;
            left: 50%;
            transform: translateX(-50%);
        }
        .nav-span {
            margin: 0 15px;
            color: #d23369;
            text-decoration: none;
            font-weight: bold;
            padding: 5px 10px;
            border-radius: 5px;
            transition: all 0.3s;
        }
        .nav-span:hover {
            background-color: #ffebee;
            color: #ff4081;
        }
        .space {
            flex-grow: 1;
        }
        .container {
            display: flex;
            padding-top: 90px;
            min-height: calc(100vh - 90px);
            box-sizing: border-box;
        }
        .left, .center, .right {
            padding: 20px;
            box-sizing: border-box;
        }
        .left {
            width: 25%;
            background: rgba(255,255,255,0.8);
            border-left: 2px dashed #ffb8c6;
            height: calc(100vh - 130px);
            overflow-y: auto;
        }
        .center {
            width: 50%;
            background: rgba(255,255,255,0.9);
            height: calc(100vh - 130px);
            overflow-y: auto;
        }
        .right {
            width: 25%;
            background: rgba(255,255,255,0.8);
            border-left: 2px dashed #ffb8c6;
            height: calc(100vh - 130px);
            overflow-y: auto;
        }
        .card {
            background: white;
            border-radius: 15px;
            padding: 20px;
            margin-bottom: 20px;
            box-shadow: 0 5px 15px rgba(210, 51, 105, 0.1);
            border: 1px solid #ffd6de;
            position: relative;
        }
        .card:before {
            content: "🎀";
            position: absolute;
            top: -10px;
            left: -10px;
            font-size: 20px;
        }
        .user-info img {
            width: 100px;
            height: 100px;
            border-radius: 25%;
            border: 3px solid #ff8e9e;
            object-fit: cover;
            margin-bottom: 15px;
        }
        .user-info h3 {
            color: #d23369;
            margin: 10px 0;
        }
        .user-info p {
            color: #666;
            margin: 5px 0;
        }
        .developer-info {
            text-align: center;
        }
        .developer-info h3 {
            color: #d23369;
            border-bottom: 2px dotted #ffb8c6;
            padding-bottom: 10px;
        }
        .developer-info p {
            color: #666;
            line-height: 1.6;
            margin: 8px 0;
        }
        .copyright {
            font-size: 12px;
            color: #999;
            margin-top: 15px;
        }
        .form-group {
            margin-bottom: 20px;
        }
        .form-label {
            display: block;
            margin-bottom: 8px;
            color: #d23369;
            font-weight: bold;
        }
        .form-control {
            width: 100%;
            padding: 12px;
            border: 2px solid #ffb8c6;
            border-radius: 10px;
            font-family: 'Comic Sans MS', cursive, sans-serif;
            font-size: 16px;
            box-sizing: border-box;
            transition: all 0.3s;
        }
        .form-control:focus {
            border-color: #ff6b88;
            outline: none;
            box-shadow: 0 0 0 3px rgba(255, 107, 136, 0.2);
        }
        textarea.form-control {
            min-height: 200px;
            resize: vertical;
        }
        .btn-submit {
            background-color: #d23369;
            color: white;
            border: none;
            padding: 12px 25px;
            border-radius: 25px;
            font-weight: bold;
            cursor: pointer;
            box-shadow: 0 4px 8px rgba(210, 51, 105, 0.3);
            transition: all 0.3s;
            font-size: 16px;
            display: block;
            margin: 0 auto;
        }
        .btn-submit:hover {
            background-color: #ff4081;
            transform: translateY(-2px);
            box-shadow: 0 6px 12px rgba(210, 51, 105, 0.4);
        }
        .publish-title {
            text-align: center;
            color: #d23369;
            margin-bottom: 30px;
            font-size: 24px;
        }
        .publish-title:before {
            content: "✨";
            margin-right: 10px;
        }
        .publish-title:after {
            content: "✨";
            margin-left: 10px;
        }
    </style>
</head>
<body>
    <div class="nav">
        <img src="pic/cat.jpg" alt="小猫" title="小公主生日快乐">
        <span class="blog-title">星辰诞愿 - 发布公告</span>
        <div class="nav-links">
            <a class="nav-span" href="home.html">主页</a>
            <a class="nav-span" href="notice.html">公告</a>
        </div>
        <div class="space"></div>
    </div>
    <div class="container">
        <div class="left">
            <div class="card developer-info">
                <img src="pic/mohan.jpg" title="小公主生日快乐" alt="开发者logo" width="320">
                <p class="birthday-theme">🎁 让祝福传递温暖 🎁</p>
                <p class="copyright">© 2025 星辰诞愿 版权所有</p>
            </div>
        </div>
        <div class="center">
            <div class="card">
                <h2 class="publish-title">发布公告</h2>
                <form id="noticeForm">
                    <div class="form-group">
                        <label for="title" class="form-label">公告标题</label>
                        <input type="text" id="title" class="form-control" placeholder="请输入公告标题" required>
                    </div>
                    <div class="form-group">
                        <label for="content" class="form-label">公告内容</label>
                        <textarea id="content" class="form-control" placeholder="请输入公告内容" required></textarea>
                    </div>
                    <button type="submit" class="btn-submit">发布公告</button>
                </form>
            </div>
        </div>
        <div class="right">
            <div class="card developer-info">
                <img id="user-develop" src="pic/logo.png" title="小公主生日快乐" alt="开发者logo" width="320">
                <h3>星辰诞愿系统</h3>
                <p>✨ 生日祝福专属平台 ✨</p>
                <p>版本: Linhan002 生日特别版</p>
                <p>开发者: 九转苍翎</p>
                <p>联系QQ: 3210728077</p>
                <p>邮箱: 3210728077@qq.com</p>
                <p class="birthday-theme">🎁 让祝福传递温暖 🎁</p>
                <p class="copyright">© 2025 星辰诞愿 版权所有</p>
            </div>
        </div>
    </div>
    <script src="js/jquery.min.js"></script>
    <script src="js/common.js"></script>
    <script>
        $(document).ready(function() {
            // 表单提交处理
            $("#noticeForm").submit(function(e) {
                e.preventDefault();
                let title = $("#title").val();
                let content = $("#content").val();
                if (!title || !content) {
                    alert("请填写完整的公告信息");
                    return;
                }
                $.ajax({
                    type: "post",
                    url: "notice/publish",
                    contentType: "application/json",
                    data: JSON.stringify({
                        title: title,
                        context: content
                    }),
                    success: function(result) {
                        if (result.code === "SUCCESS") {
                            alert("公告发布成功！");
                            location.href = "notice.html";
                        } else {
                            alert(result.errorMessage);
                        }
                    },
                    error: function(error) {
                        if (error.status === 401) {
                            location.href = "login.html";
                        }
                    }
                });
            });
            // 检查用户权限
            $.ajax({
                type: "get",
                url: "user/getLoginUser",
                success: function(result) {
                    if (result.code === "SUCCESS" && result.data != null) {
                        if (result.data.power === 0) {
                            alert("您没有发布公告的权限");
                            window.location.href = "notice.html";
                        }
                    } else {
                        alert("请先登录");
                        window.location.href = "login.html";
                    }
                },
                error: function(error) {
                    if (error != null && error.status === 401) {
                        alert("请先登录");
                        window.location.href = "login.html";
                    }
                }
            });
        });
    </script>
</body>
</html>